package com.baidu.user.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.baidu.pojo.User;
import com.baidu.user.service.OauthService;


@Controller
public class OauthController {
	
		@Autowired
		private  OauthService service;
		
		
		@RequestMapping("index")
		public String index(){
			return "index";
		}
		
		
		
		@RequestMapping("oauthMsg")
		public String oauthMsg(String code ,HttpServletRequest request){
		
			User userinfo=service.dooauthMsg(code,request);
	
			request.getSession().setAttribute("userinfo", userinfo);
			System.out.println("~~~~~~"+request.getSession().getAttribute("userinfo"));
			return "redirect:/index.jsp";
			}
		
}
